//
//  ComMethod.m
//  TengyunStation
//
//  Created by Johnny on 15/8/21.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "ComMethod.h"
#import "AdModel.h"
#import "EveryExpress.h"
#import "ExpressCompany.h"
#import "Message.h"
#import "MessageDetail.h"
#import "ReceivedExpress.h"
#import "ReturnExpress.h"
#import "StatisticsCount.h"
#import "WaitTakingExpress.h"
#import "SendSMSTime.h"
#import "TSHeader.h"

@implementation ComMethod

+ (NSString *)getVersion {
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    return [infoDictionary objectForKey:@"CFBundleShortVersionString"];
}

+ (NSString *)getTodayYYYYMMDDHHmmss {
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    return [dateFormatter stringFromDate:[NSDate date]];
}

+ (BOOL)judgeIsLegal:(NSString *)string Limit:(NSString *)limit {
    if ([limit isEqualToString:TelephoneLimit]) {
        if (string.length != 11 || ![string hasPrefix:@"1"]) {
            return NO;
        }
    }
    NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:limit] invertedSet];
    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
    if (![string isEqualToString:filtered]) {
        return NO;
    }
    return YES;
}

+ (void)clearJKDBModelData {
    [AdModel clearTable];
    [EveryExpress clearTable];
    [ExpressCompany clearTable];
    [Message clearTable];
    [MessageDetail clearTable];
    [ReceivedExpress clearTable];
    [ReturnExpress clearTable];
    [StatisticsCount clearTable];
    [WaitTakingExpress clearTable];
    [SendSMSTime clearTable];
}

@end
